package src.main.java.chapter2;

/**
 * @author lwx
 * @create 2016-09-25 17:36
 */
public class Lesson2 {


    public static void main(String[] args) {

        Builder builder
                = new Builder(1);
        builder.createName("lwx").createHeight("175");

        System.out.println(builder.print());

    }

}

class Builder {

    private int version;

    private String name;

    private String hegith;

    private String width;

    private float price;

    //必定需要的属性，可以放入到构造函数中
    public Builder(int version) {

        this.version = version;
    }

    public Builder createName(String name) {
        this.name = name;
        return this;

    }

    public Builder createHeight(String hegith) {
        this.hegith = hegith;
        return this;

    }
    //其他属性 and so on

    public String print() {
        return "name:" + name + "\theight:" + hegith;
    }
}